import Vue from 'vue'
import Vuex from 'vuex'
import { getItem,setItem } from '@/utils/localStorage';
import { TOKEN_KEY } from '@/utils/assets_text';
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user:getItem(TOKEN_KEY),// 对象包含token 和 临时token
  },
  mutations: {
    setUser(state,user){//登录成功 修改token
      state.user = user
      setItem(TOKEN_KEY,user)//存本地
      // localStorage.setItem(TOKEN_KEY,JSON.stringify(user))
    },
  },
  actions: {

  },
  getters: {

  },
  modules: {
    
  }
})
